### CODE FOR:
###
### Putting the partisan influence into political context:
### How party attachment and policy preference shape the effect of party cues
###
### PART 3: Examining the overall effect of party cues
###         The results are included in the paper as Table 1 and Figure 3.
###
### VERSION: 2023-MAY-11


rm(list=ls())
gc()


setwd("C:/Users/miros/Desktop/Research/Finland - Party cues in the context of policy preferences")




# LOADING LIBRARIES -------------------------------------------------------
library(haven)
library(dplyr)
library(ggplot2)
library(fixest)
library(tableHTML)
library(grid)
library(ggpubr)
library(RColorBrewer)





# DATA --------------------------------------------------------------------

# _ Import ---------------------------------------------------------------
# NOTE: The data file loaded in the next step was prepared in a separate
#       scripts '01_CuesInContext_data-prep.R'. If you haven't run the script, 
#       return to the depository and run that script first. Its output is 
#       'BIBU_long.Rda' loaded in the next step.

load("02-data/BIBU_long.Rda")





# DATA ADJUSTMENTS --------------------------------------------------------
# NOTE: The following part reshapes the data into a suitable format for the
#       fixed effects model estimation.


# Creating two subsets of data (one for each policy reform)
BIBU.long.TUBE <- na.omit(BIBU.long[c("RETIREMENT_TUBE", "MEMBERID", "ROUND", "GovParty.Overall")])
BIBU.long.SCHOOLING <- na.omit(BIBU.long[c("COMPULSORY_SCHOOLING", "MEMBERID", "ROUND", "GovParty.Overall")])

# Identifying those 'MEMBERID' which are included twice in the data.
# NOTE: The goal is to subset only those individuals who participated in
#       both waves and we have two data points for each of them.
BIBU.long.TUBE.twice <- data.frame(table(BIBU.long.TUBE$MEMBERID))
BIBU.long.TUBE.twice$Include <- ifelse(BIBU.long.TUBE.twice$Freq == 2, 1, 0)

BIBU.long.SCHOOLING.twice <- data.frame(table(BIBU.long.SCHOOLING$MEMBERID))
BIBU.long.SCHOOLING.twice$Include <- ifelse(BIBU.long.SCHOOLING.twice$Freq == 2, 1, 0)

# Attaching the 'Include' variable (identifying respondents participating in both waves)
BIBU.long.TUBE <- merge(BIBU.long.TUBE, 
                        BIBU.long.TUBE.twice[c("Var1", "Include")], 
                        by.x = "MEMBERID", by.y = "Var1")
BIBU.long.SCHOOLING <- merge(BIBU.long.SCHOOLING, 
                             BIBU.long.SCHOOLING.twice[c("Var1", "Include")], 
                             by.x = "MEMBERID", by.y = "Var1")

# Subsetting only relevant observations (i.e., people participating in both waves)
BIBU.long.TUBE <- subset(BIBU.long.TUBE, Include == 1)
BIBU.long.SCHOOLING <- subset(BIBU.long.SCHOOLING, Include == 1)

# Removing irrelevant objects and variables
BIBU.long.TUBE$Include <- NULL
BIBU.long.SCHOOLING$Include <- NULL
rm(BIBU.long.TUBE.twice, BIBU.long.SCHOOLING.twice)

# NOTE: Now, 'BIBU.long.TUBE' and 'BIBU.long.SCHOOLING' include only 
#       respondents participating in both waves and hence the objects
#       are ready for fixed effects model estimation.





# ANALYSIS ----------------------------------------------------------------
# NOTE: The following part of the analysis replicates the (overall) effect
#       of the party cues on voters' policy preferences. Estimated are
#       fixed effects models examining the revealed individual-level
#       shifts in policy preferences regarding the two reforms enacted by
#       the Finnish government.




# _ TABLE A1: Models ------------------------------------------------------

# Adjusting the factor levels (so the relevant coefficients relate to the
# government voters - i.e., the main group of interest)
BIBU.long.TUBE$GovParty.Overall <- factor(BIBU.long.TUBE$GovParty.Overall,
                                          levels = c("Opposition voters", 
                                                     "Government voters"))

BIBU.long.SCHOOLING$GovParty.Overall <- factor(BIBU.long.SCHOOLING$GovParty.Overall,
                                               levels = c("Opposition voters", 
                                                          "Government voters"))


# __ Model estimation -----------------------------------------------------

# Model 1: Abolishment of the 'Retirement Tube'
fd.model.1 <- feols(RETIREMENT_TUBE ~ ROUND*GovParty.Overall | MEMBERID, 
                    data = BIBU.long.TUBE, 
                    cluster = "MEMBERID")

# Model 2: Increase of the upper age limit for compulsory schooling
fd.model.2 <- feols(COMPULSORY_SCHOOLING ~ ROUND*GovParty.Overall | MEMBERID,  
                    data = BIBU.long.SCHOOLING, 
                    cluster = "MEMBERID")

# Model(s) summary
etable(fd.model.1, fd.model.2)



# Exporting the table
write_tableHTML(
  tableHTML(
    etable(fd.model.1, fd.model.2, tex = FALSE)), 
  file = "04-figures and models/Tab A1 - government vs opposition overall change.html")


# Cleanup
rm(fd.model.1, fd.model.2)





# _ FIGURE 2 --------------------------------------------------------------

# __ Model (re)estimation -------------------------------------------------
# NOTE: In the first step, the models are re-generated for convenience. The 
#       reason is the newly generated model outputs below provide directly 
#       the coefficients that can be used for visualizations in Figure 2. 


# Model 1: Abolishment of the 'Retirement Tube'
fd.model.1 <- feols(RETIREMENT_TUBE ~ i(ROUND, GovParty.Overall, "Round 1") | MEMBERID, 
                    data = BIBU.long.TUBE, 
                    cluster = "MEMBERID")

# Model 2: Increase of the upper age limit for compulsory schooling
fd.model.2 <- feols(COMPULSORY_SCHOOLING ~ i(ROUND, GovParty.Overall, "Round 1") | MEMBERID, 
                    data = BIBU.long.SCHOOLING, 
                    cluster = "MEMBERID")

# Model(s) summary
etable(fd.model.1, fd.model.2)



# __ Extracting the marginal effects --------------------------------------
margins <-
  data.frame(
    rbind(
      c("Abolishment of\nthe 'Retirement Tube'",      "Before\nthe reform\n(September 2020)", "Government\nvoters", 0, 0, 0),
      c("Abolishment of\nthe 'Retirement Tube'",      "Before\nthe reform\n(September 2020)", "Opposition\nvoters", 0, 0, 0),
      c("Abolishment of\nthe 'Retirement Tube'",      "After\nthe reform\n(February 2021)","Opposition\nvoters", broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "conf.low", "conf.high")]),
      c("Abolishment of\nthe 'Retirement Tube'",      "After\nthe reform\n(February 2021)","Government\nvoters", broom::tidy(fd.model.1, conf.int = .95)[2 , c("estimate", "conf.low", "conf.high")]),
      c("Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)", "Government\nvoters", 0, 0, 0),
      c("Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)", "Opposition\nvoters", 0, 0, 0),
      c("Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)","Opposition\nvoters", broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "conf.low", "conf.high")]),
      c("Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)","Government\nvoters", broom::tidy(fd.model.2, conf.int = .95)[2 , c("estimate", "conf.low", "conf.high")])
    ))

# Changing column names
names(margins) <- c("reform", "time", "group", "estimate", "conf.low", "conf.high")

# Unlisting the rows
margins$reform <- factor(unlist(margins$reform), levels = c("Abolishment of\nthe 'Retirement Tube'", "Extension of\nthe compulsory schooling age"))
margins$time <- factor(unlist(margins$time), levels = c("Before\nthe reform\n(September 2020)", "After\nthe reform\n(February 2021)"))
margins$group <- factor(unlist(margins$group), levels = c("Government\nvoters", "Opposition\nvoters"))
margins$estimate <- as.numeric(unlist(margins$estimate))
margins$conf.low <- as.numeric(unlist(margins$conf.low))
margins$conf.high <- as.numeric(unlist(margins$conf.high))




# __ Figure ---------------------------------------------------------------

ggarrange(
  
  # Abolishment of the retirement tube
  ggplot(subset(margins, reform == "Abolishment of\nthe 'Retirement Tube'"), 
         aes(x = time, y = estimate, group = group, color = group)) +
    geom_hline(yintercept = 0, colour = "grey60", linetype = "longdash") +
    geom_point(aes(group = group, color = group), position = position_dodge(width = 0.2)) +
    geom_line(aes(group = group, color = group), position = position_dodge(width = 0.2)) +
    geom_errorbar(aes(ymin = conf.low, ymax = conf.high, group = group, color = group), width = 0.2, position = position_dodge(width = 0.2)) +
    scale_y_continuous(breaks = seq(-0.75, 0.75, 0.125), labels = c("-0.75", "", "-0.50", "", "-0.25", "", "0.00", "", "0.25", "", "0.50", "", "0.75")) +
    scale_color_manual(values = c(brewer.pal(n = 3, name = "Set1"))) +
    geom_rect(ymin = 0.75, ymax = 1, xmin = 0.5, xmax = 2.5, colour = "black", fill = "grey90") +
    annotate("text", x = 1.5, y = 0.875, hjust = 0.5, vjust = -0.20, label = "Unpopular policy reform", fontface = 2, size = 11/.pt) +
    annotate("text", x = 1.5, y = 0.875, hjust = 0.5, vjust =  1.60, label = "Abolition of the 'retirement tube'", size = 8/.pt) +
    coord_cartesian(xlim = c(0.5, 2.5), ylim = c(-0.75, 1), expand = FALSE, clip = "off") +
    labs(y = expression(paste(symbol('\254'), " Lower support ",~-~bold(Estimate)~-~" Higher support ", symbol('\256'), "                ")), x = NULL, title = NULL) +
    theme(legend.position = "right",
          legend.background = element_rect(),
          legend.key = element_blank(),
          legend.key.width = unit(1, "cm"),
          legend.key.height = unit(1, "cm"),
          legend.spacing = unit(1, "cm"),
          legend.text.align = 0,
          legend.title.align = 0,
          legend.title = element_blank(),
          legend.box.just = "center",
          axis.title.y = element_text(size = 8),
          axis.text = element_text(size = 8),
          panel.grid.major.x = element_blank(), 
          panel.grid.major.y = element_line(colour = "gray90"), 
          panel.grid.minor.y = element_line(colour = "gray90"),
          panel.background = element_rect(fill = "transparent", colour = "black"),
          plot.background = element_rect(fill = "transparent", colour = "transparent"),
          panel.border = element_rect(fill = "transparent", colour = "black"),
          axis.ticks.y = element_blank(),
          plot.margin = unit(c(0.05, 0.05, 0.05, 0.05),"cm")),
  
  
  # Compulsory schooling extension
  ggplot(subset(margins, reform == "Extension of\nthe compulsory schooling age"), 
         aes(x = time, y = estimate, group = group, color = group)) +
    geom_hline(yintercept = 0, colour = "grey60", linetype = "longdash") +
    geom_point(aes(group = group, color = group), position = position_dodge(width = 0.2)) +
    geom_line(aes(group = group, color = group), position = position_dodge(width = 0.2)) +
    geom_errorbar(aes(ymin = conf.low, ymax = conf.high, group = group, color = group), width = 0.2, position = position_dodge(width = 0.2)) +
    scale_y_continuous(breaks = seq(-0.75, 0.75, 0.125), labels = c("-0.75", "", "-0.50", "", "-0.25", "", "0.00", "", "0.25", "", "0.50", "", "0.75")) +
    scale_color_manual(values = c(brewer.pal(n = 3, name = "Set1"))) +
    geom_rect(ymin = 0.75, ymax = 1, xmin = 0.5, xmax = 2.5, colour = "black", fill = "grey90") +
    annotate("text", x = 1.5, y = 0.875, hjust = 0.5, vjust = -0.20, label = "Popular policy reform", fontface = 2, size = 11/.pt) +
    annotate("text", x = 1.5, y = 0.875, hjust = 0.5, vjust =  1.60, label = "Extension of the compulsory schooling age", size = 8/.pt) +
    coord_cartesian(xlim = c(0.5, 2.5), ylim = c(-0.75, 1), expand = FALSE, clip = "off") +
    labs(y = NULL, x = NULL, title = NULL) +
    theme(legend.position = "right",
          legend.background = element_rect(),
          legend.key = element_blank(),
          legend.key.width = unit(1, "cm"),
          legend.key.height = unit(1, "cm"),
          legend.spacing = unit(1, "cm"),
          legend.text.align = 0,
          legend.title.align = 0,
          legend.title = element_blank(),
          legend.box.just = "center",
          axis.title.y = element_text(size = 9),
          axis.text.y = element_blank(),
          axis.text = element_text(size = 8),
          panel.grid.major.x = element_blank(), 
          panel.grid.major.y = element_line(colour = "gray90"), 
          panel.grid.minor.y = element_line(colour = "gray90"),
          panel.background = element_rect(fill = "transparent", colour = "black"),
          plot.background = element_rect(fill = "transparent", colour = "transparent"),
          panel.border = element_rect(fill = "transparent", colour = "black"),
          axis.ticks.y = element_blank(),
          plot.margin = unit(c(0.05, 0.05, 0.05, 0.05),"cm")),
  
  
  # Specs
  nrow = 1, widths = c(10, 8.75), common.legend = TRUE, legend = "right") + 
  theme(panel.background = element_rect(fill = "white", color = "transparent"))



# Saving the output
ggsave(filename = "04-figures and models/Fig 3 - government vs opposition overall change.png", width = 16, height = 10, units = "cm", dpi = 600)


# Interim cleanup
rm(fd.model.1, fd.model.2, margins)




# _________________ -------------------------------------------------------
# ONLINE APPENDIX ---------------------------------------------------------
# NOTE: This part develops the analysis included as section D in the online
#       appendix which replicated the analysis, but without individual-level
#       fixed effects. The intention is to offer the results in a way
#       which allow to examine the initial level of policy support, and,
#       in the light of that, the overall effect of party cues.


# _ Replication without ID fixed effects ----------------------------------

# __ TABLE A1: Models -----------------------------------------------------
# Model 1: Abolishment of the 'Retirement Tube'
ols.model.1 <- feols(RETIREMENT_TUBE ~ ROUND*GovParty.Overall, 
                     data = BIBU.long, 
                     cluster = "MEMBERID")


# Model 2: Increase of the upper age limit for compulsory schooling
ols.model.2 <- feols(COMPULSORY_SCHOOLING ~ ROUND*GovParty.Overall, 
                     data = BIBU.long,
                     cluster = "MEMBERID")

# Model
etable(ols.model.1, ols.model.2)


# Exporting the table
write_tableHTML(
  tableHTML(etable(ols.model.1, ols.model.2, tex = FALSE, digits = 3)), 
  file = "02-figures and models/Tab A22 - policy support among groups.html")

# Finding out the number of unique observations
nrow(data.frame(unique(na.omit(BIBU.long[c("MEMBERID", "GovParty.Overall", "ROUND", "RETIREMENT_TUBE")])$MEMBERID)))
nrow(data.frame(unique(na.omit(BIBU.long[c("MEMBERID", "GovParty.Overall", "ROUND", "COMPULSORY_SCHOOLING")])$MEMBERID)))


# Extracting the marginal effects
margins <-
  data.frame(
    rbind(
      c("Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "Government\nvoters", broom::tidy(ols.model.1, conf.int = .95)[1 , c("estimate", "conf.low", "conf.high")]),
      c("Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "Opposition\nvoters", broom::tidy(ols.model.1, conf.int = .95)[3 , c("estimate", "conf.low", "conf.high")] + broom::tidy(ols.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "Government\nvoters", broom::tidy(ols.model.1, conf.int = .95)[2 , c("estimate", "conf.low", "conf.high")] + broom::tidy(ols.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "Opposition\nvoters", broom::tidy(ols.model.1, conf.int = .95)[4 , c("estimate", "conf.low", "conf.high")] + broom::tidy(ols.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(ols.model.1, conf.int = .95)[2 , c("estimate", "estimate", "estimate")] + broom::tidy(ols.model.1, conf.int = .95)[3 , c("estimate", "estimate", "estimate")]),
      
      c("Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "Government\nvoters", broom::tidy(ols.model.2, conf.int = .95)[1 , c("estimate", "conf.low", "conf.high")]),
      c("Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "Opposition\nvoters", broom::tidy(ols.model.2, conf.int = .95)[3 , c("estimate", "conf.low", "conf.high")] + broom::tidy(ols.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "Government\nvoters", broom::tidy(ols.model.2, conf.int = .95)[2 , c("estimate", "conf.low", "conf.high")] + broom::tidy(ols.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "Opposition\nvoters", broom::tidy(ols.model.2, conf.int = .95)[4 , c("estimate", "conf.low", "conf.high")] + broom::tidy(ols.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(ols.model.2, conf.int = .95)[2 , c("estimate", "estimate", "estimate")] + broom::tidy(ols.model.2, conf.int = .95)[3 , c("estimate", "estimate", "estimate")])
    ))


# Changing names
names(margins) <- c("reform", "time", "group", "estimate", "conf.low", "conf.high")

# Unlisting the rows
margins$reform <- factor(unlist(margins$reform), levels = c("Abolishment of\nthe 'Retirement Tube'", "Extension of\nthe compulsory schooling age"))
margins$time <- factor(unlist(margins$time), levels = c("Before\nthe reform\n(September 2020)", "After\nthe reform\n(February 2021)"))
margins$group <- factor(unlist(margins$group), levels = c("Government\nvoters", "Opposition\nvoters"))
margins$estimate <- as.numeric(unlist(margins$estimate))
margins$conf.low <- as.numeric(unlist(margins$conf.low))
margins$conf.high <- as.numeric(unlist(margins$conf.high))



# __ FIGURE 3 ---------------------------------------------------------------
ggarrange(
  # Abolishment of the retirement tube
  ggplot(subset(margins, reform == "Abolishment of\nthe 'Retirement Tube'"), 
         aes(x = time, y = estimate, group = group, color = group)) +
    geom_hline(yintercept = c(2, 3), color = "grey75") +
    geom_point(aes(group = group, color = group), position = position_dodge(width = 0.2)) +
    geom_line(aes(group = group, color = group), position = position_dodge(width = 0.2)) +
    geom_errorbar(aes(ymin = conf.low, ymax = conf.high, group = group, color = group), width = 0.2, position = position_dodge(width = 0.2)) +
    scale_y_continuous(breaks = seq(1, 4, 0.5), labels = c("1 (Strongly disagree)", "", "2 (Disagree)", "", "3 (Agree)", "", "4 (Strongly agree)")) +
    scale_color_manual(values = c(brewer.pal(n = 3, name = "Set1"))) +
    geom_rect(ymin = 4, ymax = 4.5, xmin = 0.5, xmax = 2.5, colour = "black", fill = "grey90") +
    annotate("text", x = 1.5, y = 4.25, hjust = 0.5, vjust = -0.20, label = "Unpopular policy reform", fontface = 2, size = 11/.pt) +
    annotate("text", x = 1.5, y = 4.25, hjust = 0.5, vjust =  1.60, label = "Abolition of the 'retirement tube'", size = 8/.pt) +
    coord_cartesian(xlim = c(0.5, 2.5), ylim = c(1, 4.5), expand = FALSE, clip = "off") +
    labs(y = NULL, x = NULL, title = NULL) +
    theme(legend.position = "right",
          legend.background = element_rect(),
          legend.key = element_blank(),
          legend.key.width = unit(1, "cm"),
          legend.key.height = unit(1, "cm"),
          legend.spacing = unit(1, "cm"),
          legend.text.align = 0,
          legend.title.align = 0,
          legend.title = element_blank(),
          legend.box.just = "center",
          axis.title.y = element_text(size = 8),
          axis.text = element_text(size = 8),
          panel.grid.major.x = element_blank(), 
          strip.background = element_rect(colour = "black"),
          strip.text = element_text(size = 9),
          panel.grid.major.y = element_line(colour = "gray90"), 
          panel.grid.minor.y = element_line(colour = "gray90"),
          panel.background = element_rect(fill = "transparent", colour = "black"),
          plot.background = element_rect(fill = "transparent", colour = "transparent"),
          panel.border = element_rect(fill = "transparent", colour = "black"),
          axis.ticks.y = element_blank(),
          plot.margin = unit(c(0.05, 0.05, 0.05, 0.05),"cm")),
  
  # Compulsory schooling extension
  ggplot(subset(margins, reform == "Extension of\nthe compulsory schooling age"), 
         aes(x = time, y = estimate, group = group, color = group)) +
    geom_hline(yintercept = c(2, 3), color = "grey75") +
    geom_point(aes(group = group, color = group), position = position_dodge(width = 0.2)) +
    geom_line(aes(group = group, color = group), position = position_dodge(width = 0.2)) +
    geom_errorbar(aes(ymin = conf.low, ymax = conf.high, group = group, color = group), width = 0.2, position = position_dodge(width = 0.2)) +
    scale_y_continuous(breaks = seq(1, 4, 0.5), labels = c("1 (Strongly disagree)", "", "2 (Disagree)", "", "3 (Agree)", "", "4 (Strongly agree)")) +
    scale_color_manual(values = c(brewer.pal(n = 3, name = "Set1"))) +
    geom_rect(ymin = 4, ymax = 4.5, xmin = 0.5, xmax = 2.5, colour = "black", fill = "grey90") +
    annotate("text", x = 1.5, y = 4.25, hjust = 0.5, vjust = -0.20, label = "Popular policy reform", fontface = 2, size = 11/.pt) +
    annotate("text", x = 1.5, y = 4.25, hjust = 0.5, vjust =  1.60, label = "Extension of the compulsory school age", size = 8/.pt) +
    coord_cartesian(xlim = c(0.5, 2.5), ylim = c(1, 4.5), expand = FALSE, clip = "off") +
    labs(y = NULL, x = NULL, title = NULL) +
    theme(legend.position = "right",
          legend.background = element_rect(),
          legend.key = element_blank(),
          legend.key.width = unit(1, "cm"),
          legend.key.height = unit(1, "cm"),
          legend.spacing = unit(1, "cm"),
          legend.text.align = 0,
          legend.title.align = 0,
          legend.title = element_blank(),
          legend.box.just = "center",
          axis.title.y = element_text(size = 8),
          axis.text.y = element_blank(),
          axis.text = element_text(size = 8),
          panel.grid.major.x = element_blank(), 
          strip.background = element_rect(colour = "black"),
          strip.text = element_text(size = 9),
          panel.grid.major.y = element_line(colour = "gray90"), 
          panel.grid.minor.y = element_line(colour = "gray90"),
          panel.background = element_rect(fill = "transparent", colour = "black"),
          plot.background = element_rect(fill = "transparent", colour = "transparent"),
          panel.border = element_rect(fill = "transparent", colour = "black"),
          axis.ticks.y = element_blank(),
          plot.margin = unit(c(0.05, 0.05, 0.05, 0.05),"cm")),
  
  # Specs
  nrow = 1, widths = c(10, 6.75), common.legend = TRUE, legend = "right") + 
  theme(panel.background = element_rect(fill = "white", color = "transparent"))

# Saving the output
ggsave(filename = "04-figures and models/Fig A3 - policy support among groups.png", width = 18, height = 10, units = "cm", dpi = 600)

# removing irrelevant objects
rm(ols.model.1, ols.model.2, margins)






# _ Overall effect per party ----------------------------------------------

# FIGURE A4: --------------------------------------------------------------
# __ Overall opinion shifts among party supporters ------------------------

# __ Models ---------------------------------------------------------------
# Model 1: Abolishment of the 'Retirement Tube'
fd.model.1 <- feols(RETIREMENT_TUBE ~ ROUND*PartyChoice.Overall, 
                    data = BIBU.long, 
                    cluster = "MEMBERID")


# Model 2: Increase of the upper age limit for compulsory schooling
fd.model.2 <- feols(COMPULSORY_SCHOOLING ~ ROUND*PartyChoice.Overall, 
                    data = BIBU.long,
                    cluster = "MEMBERID")

etable(fd.model.1, fd.model.2)

# NOTE: This is only a supplementary material therefore no table is
#       generated because no table is reported in the paper.




# Extracting the marginal effects

margins <-
  data.frame(
    rbind(
      
      # Government parties: Abolishment of the 'Retirement Tube'
      c("Government", "Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "Social Democrats\n(Government)", broom::tidy(fd.model.1, conf.int = .95)[4 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Government", "Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "Social Democrats\n(Government)", broom::tidy(fd.model.1, conf.int = .95)[14 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[4 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Government", "Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "Centre Party\n(Government)", broom::tidy(fd.model.1, conf.int = .95)[6 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Government", "Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "Centre Party\n(Government)", broom::tidy(fd.model.1, conf.int = .95)[16 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[6 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Government", "Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "Left Alliance\n(Government)", broom::tidy(fd.model.1, conf.int = .95)[7 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Government", "Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "Left Alliance\n(Government)", broom::tidy(fd.model.1, conf.int = .95)[17 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[7 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Government", "Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "Greens\n(Government)", broom::tidy(fd.model.1, conf.int = .95)[8 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Government", "Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "Greens\n(Government)", broom::tidy(fd.model.1, conf.int = .95)[18 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[8 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Government", "Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "Swedish People's Party\n(Government)", broom::tidy(fd.model.1, conf.int = .95)[9 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Government", "Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "Swedish People's Party\n(Government)", broom::tidy(fd.model.1, conf.int = .95)[19 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[9 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      # Opposition parties: Abolishment of the 'Retirement Tube'
      c("Opposition", "Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "National Coalition\n(Opposition)", broom::tidy(fd.model.1, conf.int = .95)[3 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Opposition", "Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "National Coalition\n(Opposition)", broom::tidy(fd.model.1, conf.int = .95)[13 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[3 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Opposition", "Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "Finns Party\n(Opposition)", broom::tidy(fd.model.1, conf.int = .95)[5 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Opposition", "Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "Finns Party\n(Opposition)", broom::tidy(fd.model.1, conf.int = .95)[15 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[5 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Opposition", "Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "Christian Democrats\n(Opposition)", broom::tidy(fd.model.1, conf.int = .95)[10 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Opposition", "Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "Christian Democrats\n(Opposition)", broom::tidy(fd.model.1, conf.int = .95)[20 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[10 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Opposition", "Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "Movement Now\n(Opposition)", broom::tidy(fd.model.1, conf.int = .95)[11 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Opposition", "Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "Movement Now\n(Opposition)", broom::tidy(fd.model.1, conf.int = .95)[21 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[11 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Opposition", "Abolishment of\nthe 'Retirement Tube'", "Before\nthe reform\n(September 2020)",  "Other\n(Opposition)", broom::tidy(fd.model.1, conf.int = .95)[12 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Opposition", "Abolishment of\nthe 'Retirement Tube'", "After\nthe reform\n(February 2021)", "Other\n(Opposition)", broom::tidy(fd.model.1, conf.int = .95)[22 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.1, conf.int = .95)[12 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.1, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      # Government parties: Increase of the upper age limit for compulsory schooling
      c("Government", "Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "Social Democrats\n(Government)", broom::tidy(fd.model.2, conf.int = .95)[4 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Government", "Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "Social Democrats\n(Government)", broom::tidy(fd.model.2, conf.int = .95)[14 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[4 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Government", "Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "Centre Party\n(Government)", broom::tidy(fd.model.2, conf.int = .95)[6 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Government", "Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "Centre Party\n(Government)", broom::tidy(fd.model.2, conf.int = .95)[16 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[6 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Government", "Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "Left Alliance\n(Government)", broom::tidy(fd.model.2, conf.int = .95)[7 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Government", "Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "Left Alliance\n(Government)", broom::tidy(fd.model.2, conf.int = .95)[17 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[7 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Government", "Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "Greens\n(Government)", broom::tidy(fd.model.2, conf.int = .95)[8 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Government", "Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "Greens\n(Government)", broom::tidy(fd.model.2, conf.int = .95)[18 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[8 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Government", "Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "Swedish People's Party\n(Government)", broom::tidy(fd.model.2, conf.int = .95)[9 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Government", "Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "Swedish People's Party\n(Government)", broom::tidy(fd.model.2, conf.int = .95)[19 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[9 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      # Opposition parties: Increase of the upper age limit for compulsory schooling
      c("Opposition", "Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "National Coalition\n(Opposition)", broom::tidy(fd.model.2, conf.int = .95)[3 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Opposition", "Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "National Coalition\n(Opposition)", broom::tidy(fd.model.2, conf.int = .95)[13 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[3 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Opposition", "Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "Finns Party\n(Opposition)", broom::tidy(fd.model.2, conf.int = .95)[5 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Opposition", "Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "Finns Party\n(Opposition)", broom::tidy(fd.model.2, conf.int = .95)[15 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[5 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Opposition", "Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "Christian Democrats\n(Opposition)", broom::tidy(fd.model.2, conf.int = .95)[10 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Opposition", "Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "Christian Democrats\n(Opposition)", broom::tidy(fd.model.2, conf.int = .95)[20 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[10 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Opposition", "Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "Movement Now\n(Opposition)", broom::tidy(fd.model.2, conf.int = .95)[11 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Opposition", "Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "Movement Now\n(Opposition)", broom::tidy(fd.model.2, conf.int = .95)[21 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[11 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[2 , c("estimate", "estimate", "estimate")]),
      
      c("Opposition", "Extension of\nthe compulsory schooling age", "Before\nthe reform\n(September 2020)",  "Other\n(Opposition)", broom::tidy(fd.model.2, conf.int = .95)[12 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")]),
      c("Opposition", "Extension of\nthe compulsory schooling age", "After\nthe reform\n(February 2021)", "Other\n(Opposition)", broom::tidy(fd.model.2, conf.int = .95)[22 , c("estimate", "conf.low", "conf.high")] + broom::tidy(fd.model.2, conf.int = .95)[12 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[1 , c("estimate", "estimate", "estimate")] + broom::tidy(fd.model.2, conf.int = .95)[2 , c("estimate", "estimate", "estimate")])
      
    ))



# Changing names
names(margins) <- c("gov_vs_opp", "reform", "time", "party", "estimate", "conf.low", "conf.high")

# Unlisting the rows
margins$gov_vs_opp <- factor(unlist(margins$gov_vs_opp), levels = c("Government", "Opposition"))

margins$reform <- unlist(margins$reform) 
margins$reform[margins$reform == "Abolishment of\nthe 'Retirement Tube'"] <- "<span style='font-size:11pt'><b>Unpopular policy reform</b></span><br><span style='font-size:7.5pt'>Abolition of the 'retirement tube'</span>"
margins$reform[margins$reform == "Extension of\nthe compulsory schooling age"] <- "<span style='font-size:11pt'><b>Popular policy reform</b></span><br><span style='font-size:7.5pt'>Extension of the compulsory school age</span>"
margins$reform <- factor(margins$reform,
                         levels = c("<span style='font-size:11pt'><b>Unpopular policy reform</b></span><br><span style='font-size:7.5pt'>Abolition of the 'retirement tube'</span>",
                                    "<span style='font-size:11pt'><b>Popular policy reform</b></span><br><span style='font-size:7.5pt'>Extension of the compulsory school age</span>"))

margins$time <- factor(unlist(margins$time), levels = c("Before\nthe reform\n(September 2020)", "After\nthe reform\n(February 2021)"))
margins$party <- factor(unlist(margins$party), levels = c("Social Democrats\n(Government)", "Centre Party\n(Government)", "Left Alliance\n(Government)", "Greens\n(Government)", "Swedish People's Party\n(Government)",
                                                          "National Coalition\n(Opposition)", "Finns Party\n(Opposition)", "Christian Democrats\n(Opposition)", "Movement Now\n(Opposition)", "Other\n(Opposition)"))
margins$estimate <- as.numeric(unlist(margins$estimate))
margins$conf.low <- as.numeric(unlist(margins$conf.low))
margins$conf.high <- as.numeric(unlist(margins$conf.high))




# __ FIGURE A4: Government parties ----------------------------------------
ggplot(subset(margins, gov_vs_opp == "Government"), aes(x = time, y = estimate, group = party)) +
  geom_hline(yintercept = c(2, 3), color = "grey75") +
  geom_point(aes(group = party), position = position_dodge(width = 0.2)) +
  geom_line(aes(group = party), position = position_dodge(width = 0.2)) +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high, group = party), width = 0.2, position = position_dodge(width = 0.2)) +
  scale_y_continuous(breaks = seq(1, 4, 0.5), labels = c("1 (Strongly disagree)", "", "2 (Disagree)", "", "3 (Agree)", "", "4 (Strongly agree)"),
                     expand = expansion(0), limits = c(1, 4)) +
  scale_color_manual(values = c(brewer.pal(n = 5, name = "Set1"))) +
  facet_grid(party ~ reform) +
  labs(y = NULL, x = NULL, title = NULL) +
  coord_cartesian(clip = "off") +
  theme(axis.title.y = element_text(size = 8),
        axis.text = element_text(size = 8),
        panel.grid.major.x = element_blank(), 
        strip.background = element_rect(colour = "black"),
        strip.background.y = element_rect(fill = brewer.pal(n = 12, name = "Paired")[5], colour = "black"),
        strip.text.y = element_text(size = 9),
        strip.text.x = element_markdown(),
        panel.grid.major.y = element_line(colour = "gray90"), 
        panel.grid.minor.y = element_line(colour = "gray90"),
        panel.background = element_rect(fill = "transparent", colour = "black"),
        panel.spacing = unit(0.75, "lines"),
        plot.background = element_rect(fill = "white", colour = "transparent"),
        panel.border = element_rect(fill = "transparent", colour = "black"),
        axis.ticks.y = element_blank(),
        plot.margin = unit(c(0.05, 0.05, 0.05, 0.05),"cm"))

# Saving the output
ggsave(filename = "04-figures and models/Fig A4 - effects per party - policy support among government.png", width = 15, height = 25, units = "cm", dpi = 600)


# __ FIGURE A5: Opposition parties ----------------------------------------
ggplot(subset(margins, gov_vs_opp == "Opposition"), aes(x = time, y = estimate, group = party)) +
  geom_hline(yintercept = c(2, 3), color = "grey75") +
  geom_point(aes(group = party), position = position_dodge(width = 0.2)) +
  geom_line(aes(group = party), position = position_dodge(width = 0.2)) +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high, group = party), width = 0.2, position = position_dodge(width = 0.2)) +
  scale_y_continuous(breaks = seq(1, 4, 0.5), labels = c("1 (Strongly disagree)", "", "2 (Disagree)", "", "3 (Agree)", "", "4 (Strongly agree)"),
                     expand = expansion(0), limits = c(1, 4)) +
  scale_color_manual(values = c(brewer.pal(n = 5, name = "Set1"))) +
  facet_grid(party ~ reform) +
  labs(y = NULL, x = NULL, title = NULL) +
  coord_cartesian(clip = "off") +
  theme(axis.title.y = element_text(size = 8),
        axis.text = element_text(size = 8),
        panel.grid.major.x = element_blank(), 
        strip.background = element_rect(colour = "black"),
        strip.background.y = element_rect(fill = brewer.pal(n = 12, name = "Paired")[1], colour = "black"),
        strip.text.y = element_text(size = 9),
        strip.text.x = element_markdown(),
        panel.grid.major.y = element_line(colour = "gray90"), 
        panel.grid.minor.y = element_line(colour = "gray90"),
        panel.background = element_rect(fill = "transparent", colour = "black"),
        panel.spacing = unit(0.75, "lines"),
        plot.background = element_rect(fill = "white", colour = "transparent"),
        panel.border = element_rect(fill = "transparent", colour = "black"),
        axis.ticks.y = element_blank(),
        plot.margin = unit(c(0.05, 0.05, 0.05, 0.05),"cm"))

# Saving the output
ggsave(filename = "04-figures and models/Fig A5 - effects per party - policy support among opposition.png", width = 15, height = 25, units = "cm", dpi = 600)



# Final cleanup
rm(fd.model.1, fd.model.2, margins, BIBU.long, BIBU.long.SCHOOLING, BIBU.long.TUBE)



